package com.aspose.cells.a.c;

import com.aspose.cells.a.d.zbi;
import com.aspose.cells.a.d.zby;
import com.aspose.cells.a.d.zfq;
import com.aspose.cells.a.d.zfs;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

public class zn {
   public static com.aspose.cells.b.a.b.zs a(com.aspose.cells.b.a.b.zs var0) {
      return new com.aspose.cells.b.a.b.zs(var0.b(), var0.c());
   }

   public static com.aspose.cells.b.a.b.zq a(com.aspose.cells.b.a.b.zp var0) {
      return new com.aspose.cells.b.a.b.zq((float)var0.c(), (float)var0.d(), (float)var0.e(), (float)var0.f());
   }

   public static com.aspose.cells.b.a.b.zp b(com.aspose.cells.b.a.b.zp var0) {
      return new com.aspose.cells.b.a.b.zp(var0.c(), var0.d(), var0.e(), var0.f());
   }

   public static com.aspose.cells.b.a.b.zq a(com.aspose.cells.b.a.b.zq var0) {
      return new com.aspose.cells.b.a.b.zq(var0.f(), var0.g(), var0.h(), var0.i());
   }

   public static com.aspose.cells.b.a.b.zq a(com.aspose.cells.b.a.b.a.ze var0) {
      Rectangle var1 = var0.getBounds();
      return new com.aspose.cells.b.a.b.zq((float)var1.getX(), (float)var1.getY(), (float)var1.getWidth(), (float)var1.getHeight());
   }

   public static int[] a(boolean var0, byte[] var1, int var2) {
      int[] var3 = new int[2];

      try {
         com.aspose.cells.b.a.d.zh var4 = new com.aspose.cells.b.a.d.zh(var1);
         com.aspose.cells.b.a.b.zj var5 = com.aspose.cells.b.a.b.zj.a((com.aspose.cells.b.a.d.zm)var4);
         boolean var6 = (var5.g() & 4096) == 4096;
         double var7 = 96.0D;
         double var9 = 96.0D;
         if (var6) {
            var7 = (double)var5.j();
            var9 = (double)var5.k();
         }

         if (var0) {
            if (var6) {
               var3[0] = (int)((double)(var5.i() * var2) / var7 + 0.5D);
               var3[1] = (int)((double)(var5.h() * var2) / var9 + 0.5D);
            } else {
               var3[0] = var5.i();
               var3[1] = var5.h();
            }
         } else {
            var3[0] = (int)((double)(var5.i() * var2) / var7 + 0.5D);
            var3[1] = (int)((double)(var5.h() * var2) / var9 + 0.5D);
         }

         var5.d();
         var4.a();
      } catch (Exception var11) {
         ;
      }

      return var3;
   }

   public static zfq a(String var0, int var1) {
      try {
         return zfs.b(var0, var1, false);
      } catch (Exception var3) {
         throw new IllegalArgumentException(var3);
      }
   }

   public static int a(String var0, zfq var1, int var2) {
      try {
         return var1.b(var0, (float)var2);
      } catch (Exception var4) {
         throw new IllegalArgumentException(var4);
      }
   }

   public static int a(String var0, String var1, float var2, int var3) {
      if (com.aspose.cells.a.za.c == 3 && var1.equals("Calibri")) {
         return (int)((double)a((FontMetrics)null, (zfq)null, var0, var1, var2, var3) + 0.5D);
      } else {
         try {
            zfq var4 = zfs.b(var1, var3, false);
            return var4.b(var0, var2);
         } catch (Exception var5) {
            throw new IllegalArgumentException(var5);
         }
      }
   }

   public static float a(char var0, zfq var1, int var2) {
      try {
         return var1.b(var0, (float)var2);
      } catch (Exception var4) {
         throw new IllegalArgumentException(var4);
      }
   }

   public static float a(char var0, String var1, int var2, int var3) {
      if (com.aspose.cells.a.za.c == 3 && var1.equals("Calibri")) {
         StringBuilder var8 = new StringBuilder();
         byte var5 = 100;

         for(int var6 = 0; var6 < var5; ++var6) {
            var8.append(var0);
         }

         return a((FontMetrics)null, (zfq)null, var8.toString(), var1, (float)var2, var3) / (float)var5;
      } else {
         try {
            zfq var4 = zfs.b(var1, var3, false);
            return var4.b(var0, (float)var2);
         } catch (Exception var7) {
            throw new IllegalArgumentException(var7);
         }
      }
   }

   public static float a(String var0, int var1, int var2) {
      if (com.aspose.cells.a.za.c == 3 && var0.equals("Calibri")) {
         return a((FontMetrics)null, (zfq)null, "1234567890", var0, (float)var1, var2) / 10.0F;
      } else {
         try {
            zfq var3 = zfs.b(var0, var2, false);
            float var4 = -1.0F;

            for(int var6 = 0; var6 < 10; ++var6) {
               float var5 = var3.b((char)(48 + var6), (float)var1);
               if (var5 > var4) {
                  var4 = var5;
               }
            }

            return var4;
         } catch (Exception var7) {
            throw new IllegalArgumentException(var7);
         }
      }
   }

   public static float a(FontMetrics var0, zfq var1, String var2, String var3, float var4, int var5) {
      if (!var2.equals((Object)null) && !var2.equals("")) {
         float var6 = 0.0F;
         boolean var7 = false;

         try {
            if (var0 == null) {
               com.aspose.cells.b.a.b.zg var8 = new com.aspose.cells.b.a.b.zg(var3, var4, var5);
               Font var9 = var8.a();
               BufferedImage var10 = new BufferedImage(1, 1, 1);
               Graphics2D var11 = (Graphics2D)var10.getGraphics();
               var0 = var11.getFontMetrics(var9);
            }

            var6 = (float)var0.stringWidth(var2);
         } catch (Exception var13) {
            var7 = true;
         }

         if (var6 == 0.0F || var7) {
            try {
               if (var1 == null) {
                  var1 = zfs.b(var3, var5, false);
               }

               var6 = (float)var1.b(var2, var4);
            } catch (Exception var12) {
               throw new IllegalArgumentException(var12);
            }
         }

         return var6;
      } else {
         return 0.0F;
      }
   }

   public static float b(FontMetrics var0, zfq var1, String var2, String var3, float var4, int var5) {
      if (!var2.equals((Object)null) && !var2.equals("")) {
         float var6 = 0.0F;

         try {
            if (var1 == null) {
               var1 = zfs.b(var3, var5, false);
            }

            var6 = (float)var1.b(var2, var4);
         } catch (Exception var12) {
            if (var0 == null) {
               com.aspose.cells.b.a.b.zg var8 = new com.aspose.cells.b.a.b.zg(var3, var4, var5);
               Font var9 = var8.a();
               BufferedImage var10 = new BufferedImage(1, 1, 1);
               Graphics2D var11 = (Graphics2D)var10.getGraphics();
               var0 = var11.getFontMetrics(var9);
            }

            var6 = (float)var0.stringWidth(var2);
         }

         return var6;
      } else {
         return 0.0F;
      }
   }

   public static zbi a(String var0) {
      return new zby();
   }
}
